home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 32
/
Mac Magazin and MacEasy Magazine CD - Issue 32.iso
/
Multimedia
/
PlayerPRO 4.5.5 Dev.Kit
/
Plug-Ins
/
Sound Filters Plugs
/
Amplitude.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-10-08
|
4KB
|
154 lines
/*
Player PRO 4.4x PlugIns
Antoine ROSSET
16 Tranchees
1206 GENEVA
SWITZERLAND
FAX: 022 789 35 03
Compuserve: 100277,164
*/
#include "MAD.h"
#include "PPPlug.h"
#if defined(powerc) || defined(__powerc)
enum {
PlayerPROPlug = kCStackBased
| RESULT_SIZE(SIZE_CODE( sizeof(OSErr)))
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof( sData*)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof( long)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof( PPInfoPlug*)))
};
ProcInfoType __procinfo = PlayerPROPlug;
#else
#include <A4Stuff.h>
#endif
GDHandle TheGDevice:0xCC8;
void AutoPosition( DialogPtr aDia)
{
Point Position, mouse;
Rect ViewRect;
short XSize = (aDia->portRect.right - aDia->portRect.left), YSize = (aDia->portRect.bottom - aDia->portRect.top);
GetMouse( &mouse);
LocalToGlobal( &mouse);
SetRect( &ViewRect, (*TheGDevice)->gdRect.left + 8, (*TheGDevice)->gdRect.top + 43,
(*TheGDevice)->gdRect.right - 8, (*TheGDevice)->gdRect.bottom - 8);
Position.h = mouse.h - XSize/2;
if( Position.h + XSize >= ViewRect.right) Position.h = ViewRect.right - XSize;
else if( Position.h <= ViewRect.left) Position.h = ViewRect.left;
Position.v = mouse.v - YSize/2;
if( Position.v + YSize >= ViewRect.bottom) Position.v = ViewRect.bottom - YSize;
else if( Position.v <= ViewRect.top) Position.v = ViewRect.top;
MoveWindow( aDia, Position.h, Position.v, false);
ShowWindow( aDia);
}
Boolean getParams ( long *p1, PPInfoPlug *thePPInfoPlug)
{
DialogPtr theDialog;
Boolean theResult = false;
theDialog = GetNewDialog( 128,nil,(WindowPtr)-1);
if (theDialog) {
short iType, itemHit;
Handle iHandle;
Rect iRect;
Str255 textStr;
SetPort( theDialog);
AutoPosition( theDialog);
GetDItem(theDialog,3,&iType,&iHandle,&iRect);
NumToString( *p1, textStr);
SetIText( iHandle, textStr);
SelIText( theDialog, 3, 0, 32767);
do
{
#if defined(powerc) || defined(__powerc)
ModalDialog( thePPInfoPlug->MyDlgFilterUPP, &itemHit);
#else
ModalDialog( (ModalFilterProcPtr) thePPInfoPlug->MyDlgFilterUPP, &itemHit);
#endif
}
while ((itemHit != ok) && (itemHit != cancel));
if (itemHit == ok)
{
theResult = true;
GetDItem( theDialog, 3,&iType,&iHandle,&iRect);
GetIText( iHandle, textStr);
StringToNum( textStr, p1);
}
DisposDialog(theDialog);
}
return theResult;
}
OSErr main( sData *theData,
long SelectionStart,
long SelectionEnd,
PPInfoPlug *thePPInfoPlug)
{
long i, temp, Inc;
Ptr Sample8Ptr = theData->data;
short *Sample16Ptr = (short*) theData->data;
Inc = 120;
if( getParams( &Inc, thePPInfoPlug))
{
switch( theData->amp)
{
case 8:
Sample8Ptr += SelectionStart;
for( i = 0; i < SelectionEnd - SelectionStart; i++)
{
temp = *Sample8Ptr;
if( temp >= 0x80) temp -= 0xFF;
temp *= Inc;
temp /= 100L;
if( temp >= 127) temp = 127;
else if( temp <= -127 ) temp = -127;
*Sample8Ptr = temp;
Sample8Ptr++;
}
break;
case 16:
Sample16Ptr += SelectionStart/2; // Div 2, because it's in bytes !!!
for( i = 0; i < (SelectionEnd - SelectionStart)/2; i++) // Div 2, because it's in bytes !!!
{
temp = *Sample16Ptr;
temp *= Inc;
temp /= 100L;
if( temp >= (short) 0x7FFF) temp = 0x7FFF; // overflow ?
else if( temp <= (short) 0x8000 ) temp = (short) 0x8000;
*Sample16Ptr = temp;
Sample16Ptr++;
}
break;
}
}
return noErr;
}